#ifndef SIGNAL_H
#define SIGNAL_H
#include <unistd.h>
#include <signal.h>
#include "testbase.h"
#include "pipe.h"


namespace SIGNAL{
    Pipe *p = nullptr;
    void signal_handler(int) { if(p) p->quit(); }
    inline void test() {
        signal(SIGINT, signal_handler); // ctrl c
        signal(SIGTSTP, signal_handler); // ctrl z
        p = new Pipe;
        p->test();
        delete p;
        p = nullptr;
    }
}

class  Signal : public TestBase {
public:
    Signal(int argc, char** argv) : TestBase(argc, argv) { }

    void test() override {
        SIGNAL::test();
    }
};

#endif // SIGNAL_H
